package com.sip.stream.utils;

import android.util.Log;

import com.sip.stream.media.ZFYMediaManager;
import com.sip.stream.utils.zfy.event.ZFYMediaEvent;
import com.sip.stream.utils.zfy.voice.BeepTool;

public class ImageSaverTask implements Runnable {
    ZFYMediaEvent cacheMediaEvent;
    int format;
    int height;
    ImageSaver imageSaver;
    byte[] rawData;
    int width;

    public ImageSaverTask(byte[] bArr, ZFYMediaEvent zFYMediaEvent) {
        this.rawData = null;
        this.cacheMediaEvent = null;
        this.width = 0;
        this.height = 0;
        this.imageSaver = new ImageSaver();
        this.rawData = bArr;
        this.cacheMediaEvent = zFYMediaEvent;
        this.format = 17;
        this.width = ZFYMediaManager.getInstance().getCameraParameters().getVideoWidth();
        this.height = ZFYMediaManager.getInstance().getCameraParameters().getVideoHeight();
    }

    public ImageSaverTask(byte[] bArr, ZFYMediaEvent zFYMediaEvent, int i) {
        this.rawData = null;
        this.cacheMediaEvent = null;
        this.width = 0;
        this.height = 0;
        this.imageSaver = new ImageSaver();
        this.rawData = bArr;
        this.cacheMediaEvent = zFYMediaEvent;
        this.width = ZFYMediaManager.getInstance().getCameraParameters().getCaptrueWidth();
        this.height = ZFYMediaManager.getInstance().getCameraParameters().getCaptrueHeight();
        this.format = i;
    }

    private ImageSaverTask() {
        this.rawData = null;
        this.cacheMediaEvent = null;
        this.width = 0;
        this.height = 0;
    }

    @Override
    public void run() {
        Log.i("ImageSaverTask", "保存");
        if (this.cacheMediaEvent != null) {
            if (this.format == 256) {
                this.imageSaver.saveJPEGImage(this.rawData, this.cacheMediaEvent);
            } else {
                this.imageSaver.saveImage(this.rawData, this.cacheMediaEvent);
            }
        }
        Log.i("ImageSaverTask", "保存成功");
        BeepTool.playString("拍照成功");
    }
}
